var nowPage = 0;
var browsePlanList = {
	getData : function() {
		var name = $("#planName").val();
		var startTime = $("#startTime").val();
		var endTime = $("#endTime").val();
		checkTime(startTime, endTime);
		startTime = $("#startTime").val();
		endTime = $("#endTime").val();
		_browsePlanListGetData = $("#pageShow").myPagination({
			currPage : 1,
			pageCount : 10,
			pageNumber : 5,
			panel : {
				tipInfo_on : true,
				links : "javascript:void()"
			},
			ajax : {
				onClick : function(page) {
					ZENG.msgbox.show(" 正在加载" + page + "页，请稍后...", 6, 600);
					nowPage = page;
				},
				on : true,
				type : "POST",
				dataType : 'json',
				url : "/app/plan!getPlanListByNameAndPage",
				param : {
					"planName" : name,
					"startTime" : startTime,
					"endTime" : endTime
				},
				callback : function(data) {
					backUrl.addCookie(data.state);
					if ('success' == data.state) {
						pageCountId = data.pageCount;
						browsePlanList.createContent(data.msg);
					} else if (data.state == "error") {
						errorAlert(data.msg);
					}
				}
			}
		});
	},
	createContent : function(data) {
		var ds = $("#dataShow");
		var content = "";
		ds.empty();
		if (data != null && data.length != 0) {
			$("#pageShow").show();
			content = "<tr><th width='51%' scope='col'>计划名称</th><th width='23%' scope='col'>录入时间</th>"
					+ "<th width='26%' scope='col'>操作</th></tr>";
			for ( var int = 0; int < data.length; int++) {
				var v = data[int];
				var id = v.id;
				var name = v.name;
				var time = v.inputTime;
				var count = v.countProject;
				
				var _name = name;
				if (name.length > 33) {
					name = name.substring(0, 32) + "...";
				}
				time = time.substring(0, 16);
				content += "<tr><td align='center' style='letter-spacing:5px;font-weight:bold;'><a href='/app/plan!jumpBrowsePlanItemList?planId=" + id
						+ "' target='_blank' title='" + _name + "' class='tempClass'>" + name + "（" + count
						+ "项）</a></td><td align='center'>" + time
						+ "</td><td align='center'><a href='/app/plan!jumpBrowsePlanItemList?planId=" + id
						+ "' target='_blank'>详情</a></td></tr>";
			}
		} else {
			$("#pageShow").hide();
			content = "<tr id='noData'><td align='center'><h1>暂无数据</h1></td></tr>";
		}
		ds.append(content);
		browsePlanListPoshytip();
	},
	jumpPage : function() {// 分页跳转
		_browsePlanListGetData.jumpPage(nowPage);
	}
};
/**
 * 提示层
 */
function browsePlanListPoshytip() {
	$(".tempClass").poshytip({
		className : 'tip-darkgray',
		showOn : 'hover',
		alignTo : 'target',
		alignX : 'right',
		alignY : "center",
		offsetX : 10,
		allowTipHover : true,
		fade : true,
		slide : true
	});
}
function browsePlanListOnload() {
	browsePlanList.getData();
	$("#startTime").focus(function() {
		WdatePicker({
			dateFmt : 'yyyy-MM-dd'
		});
	});
	$("#endTime").focus(function() {
		WdatePicker({
			dateFmt : 'yyyy-MM-dd'
		});
	});
	$("#search").click(function() {
		browsePlanList.getData();
	});
}